﻿using QFramework;

namespace HKTools
{
    /// <summary>
    /// 切换Target的指令
    /// </summary>
    public class CMD_ChangeCamTarget : AbstractCommand
    {
        HK_TargetEnum targetType;

        // 切换摄像机目标时，是否闪现过去
        bool isFlash = false;
        bool isUseBlinkEffect = false;

        /// <summary>
        /// 根据 HK_TargetEnum 类型，切换到对应的Target
        /// </summary>
        public CMD_ChangeCamTarget(HK_TargetEnum _targetType)
        {
            targetType = _targetType;
        }

        /// <summary>
        /// 设置 相机切换为闪现方式（取消切换过渡动画）
        /// </summary>
        public CMD_ChangeCamTarget SetUsingFlash(bool _isUseBlinkEffect = true)
        {
            isFlash = true;
            isUseBlinkEffect = _isUseBlinkEffect;
            return this;
        }

        protected override void OnExecute()
        {
            IHK_TargetCamSystem targetCamSystem = this.GetSystem<IHK_TargetCamSystem>();

            if (targetCamSystem.CurTarget != null && targetCamSystem.CurTarget.targetType == targetType)
            {
                HKDebug.LogWarning("已经在当前 Target，无需进行切换！");
                return;
            }

            targetCamSystem.ChangeTarget(targetType, isFlash, isUseBlinkEffect);
        }
    }
}